package com.shouldibuythis.android.component.quesions;

import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.app.Activity;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.shouldibuythis.android.R;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

public class QuestionDetailActivity extends Activity {

    private SlidingMenu menuL = null;
    private SlidingMenu menuR = null;
    private Activity activity = null;
    private ImageView imageView = null;

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getActionBar().hide();
        activity = this;
        setContentView(R.layout.activity_question_detail);

        imageView = (ImageView)findViewById(R.id.item_photograph);

        menuL = new SlidingMenu(activity);
        menuL.setMode(SlidingMenu.LEFT);
        menuL.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

        menuL.setBehindOffsetRes(R.dimen.sliding_menu_offset);

        menuL.setFadeDegree(0.35f);
        menuL.attachToActivity(activity, SlidingMenu.SLIDING_WINDOW);
        menuL.setMenu(R.layout.sliding_frame);

        menuR = new SlidingMenu(activity);
        menuR.setMode(SlidingMenu.RIGHT);
        menuR.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

        menuR.setBehindOffsetRes(R.dimen.sliding_menu_offset);

        menuR.setFadeDegree(0.35f);
        menuR.attachToActivity(activity, SlidingMenu.SLIDING_WINDOW);
        menuR.setMenu(R.layout.sliding_frame_red);

        setListeners();
    }

    private void setListeners(){

        menuL.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {
            @Override
            public void onOpened() {
                menuR.setSlidingEnabled(false);

                Intent intent = new Intent(activity, QuestionAnswersActivity.class);
                startActivity(intent);
                activity.finish();

            }
        });

        menuL.setOnClosedListener(new SlidingMenu.OnClosedListener() {
            @Override
            public void onClosed() {
                menuR.setSlidingEnabled(true);
            }
        });

        menuR.setOnOpenedListener(new SlidingMenu.OnOpenedListener() {
            @Override
            public void onOpened() {
                menuL.setSlidingEnabled(false);

                Intent intent = new Intent(activity, QuestionAnswersActivity.class);
                startActivity(intent);
                activity.finish();
            }
        });

        menuR.setOnClosedListener(new SlidingMenu.OnClosedListener() {
            @Override
            public void onClosed() {
                menuL.setSlidingEnabled(true);
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.question_detail, menu);

        return true;
    }
    
}
